﻿using HalconDotNet;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            HObject img;
            HOperatorSet.GenEmptyObj(out img);
            //读取图片,这里填你的图片的位置
            HOperatorSet.ReadImage(out img, "Resources\\1.png");

            //读取形状匹配模板，路径选择你的文件路径
            HTuple modelId = new HTuple();
            HOperatorSet.ReadShapeModel("Resources\\output.shm", out modelId);

            //匹配Image中的结果
            HTuple hv_WindowHandle = new HTuple(), hv_Row1 = new HTuple();
            HTuple hv_Column1 = new HTuple(), hv_Row2 = new HTuple();
            HTuple hv_Column2 = new HTuple(), hv_ModelID = new HTuple();
            HTuple hv_Row = new HTuple(), hv_Column = new HTuple();
            HTuple hv_Angle = new HTuple(), hv_Score = new HTuple();
            //hv_Row.Dispose(); hv_Column.Dispose(); hv_Angle.Dispose(); hv_Score.Dispose();
            HOperatorSet.FindShapeModel(img, modelId, -0.39, 0.79, 0.5, 1,
    0.5, "least_squares", 0, 0.9, out hv_Row, out hv_Column, out hv_Angle, out hv_Score);

            //输出匹配结果
            Console.WriteLine($"分数:{hv_Score},Row坐标:{hv_Row},Col坐标:{hv_Column},角度:{hv_Angle}");

            Console.WriteLine("程序运行完毕！");
            Console.ReadKey();


        }
    }
}
